/**
 * 
 */
package pl.lodz.p.browarex.ws;

import java.io.File;
import java.io.IOException;

import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;

/**
 * @author Rafi
 * 
 */
@Component
public class ClasspathResourceLoader implements ResourceLoaderAware {

	private ResourceLoader loader;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.context.ResourceLoaderAware#setResourceLoader(org
	 * .springframework.core.io.ResourceLoader)
	 */
	public void setResourceLoader(ResourceLoader resourceLoader) {
		this.loader = resourceLoader;
	}

	public File getResourceAsFile(String location) throws IOException {
		Resource resource = loader.getResource(location);
		return resource.getFile();
	}

}
